/**
 *  *2010-5-16 上午01:05:37  add 
 */
package com.base.myproject.client.HR.bcode;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.base.myproject.client.busi.BaseStore;
import com.base.myproject.client.busi.LasyObejct;
import com.base.myproject.client.busi.BO.BusiObject;
import com.base.myproject.client.jdbc.StoreInfo;
import com.base.myproject.client.ui.BaseGridPanel;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
import com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.ui.Widget;

/**
 * 工作经历
 * 
 * @author Administrator 2010-5-16 javazgw@gmail.com
 */
public class Bcode_job_his extends LayoutContainer implements LasyObejct {

	BaseStore<BusiObject> mainstore = null;

	
	public Bcode_job_his(BaseStore<BusiObject> mainstore) {
		this.mainstore = mainstore;
		init();
	}

	void init() {
		 setSize(727, 336);  
		initwidget();

	}

	Widget initwidget() {
		FieldSet fs1 = new FieldSet();
		FieldSet fs2 = new FieldSet();
		fs1.add(create_job_his_t_Grid());
		fs2.add(create_job_his_a_Grid());
		fs1.setHeading("本司工作记录");
		fs2.setHeading("早前工作记录");

		VerticalPanel v = new VerticalPanel();
		v.add(fs1);
		v.add(fs2);
		this.add(v);
		return null;
	}

	BaseStore<BusiObject> jobhis_a_store = null;

	public BaseStore<BusiObject> getStore() {
		if (jobhis_a_store == null) {
			create_job_his_a_Store();
		}
		return jobhis_a_store;
	}

	BaseStore<BusiObject> create_job_his_a_Store() {
		ModelType type = new ModelType();
		type.setRoot("records");
		type.setRecordName("record");
		type.setTotalName("totle");
		type.addField("icode");
		type.getField("icode").setType(Long.class);
		type.addField("bcode");
		type.getField("bcode").setType(String.class);
		type.addField("startdate");
		type.getField("startdate").setType(Date.class);
		type.addField("enddate");
		type.getField("enddate").setType(Date.class);
		type.addField("companyname");
		type.getField("companyname").setType(String.class);
		type.addField("title");
		type.getField("title").setType(String.class);
		type.addField("salary_rmb");
		type.getField("salary_rmb").setType(Double.class);
		StoreInfo info = new StoreInfo();
		info.setTablename("bcode_job_his_a");
		info.setKeyname(new String[] { "icode" });
		info.setSql("select * from bcode_job_his_a where bcode ='{bcode}'");
		info.setParent(mainstore);// 关联主表
		info.setLinkparentcolumns(new String[] { "bcode" }); // 关联主表字段
		 info.setLinkparent_chile_columns(new String[] { "bcode" });//
		// 关联主表字段
		jobhis_a_store = new BaseStore<BusiObject>(type, info);
		return jobhis_a_store;
	}

	BaseGridPanel jobhis_a_grid = null;

	BaseGridPanel create_job_his_a_Grid() {
		CheckBoxSelectionModel cbs = new CheckBoxSelectionModel();
		List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
		columns.add(cbs.getColumn());
//
//		ColumnConfig C1 = new ColumnConfig("icode", "icode", 80);
//		columns.add(C1);
//		ColumnConfig C2 = new ColumnConfig("bcode", "bcode", 80);
//		columns.add(C2);
		ColumnConfig C3 = new ColumnConfig("startdate", "开始日期", 80);
		 DateField dateField3 = new DateField();  
		    dateField3.getPropertyEditor().setFormat(DateTimeFormat.getFormat("yyyy-MM-dd"));  
		    C3.setEditor(new CellEditor(dateField3));
		    C3.setDateTimeFormat(DateTimeFormat.getFormat("yyyy-MM-dd"));
		columns.add(C3);
		ColumnConfig C4 = new ColumnConfig("enddate", "结束日期", 80);
		 DateField dateField4 = new DateField();  
		    dateField4.getPropertyEditor().setFormat(DateTimeFormat.getFormat("yyyy-MM-dd"));  
		    C4.setEditor(new CellEditor(dateField4));
		    C4.setDateTimeFormat(DateTimeFormat.getFormat("yyyy-MM-dd"));
		columns.add(C4);
		ColumnConfig C5 = new ColumnConfig("companyname", "公司名称", 80);
		 C5.setEditor(new CellEditor(new TextField<String>()));
		columns.add(C5);
		ColumnConfig C6 = new ColumnConfig("title", "职位", 80);
		C6.setEditor(new CellEditor(new TextField<String>()));
		columns.add(C6);
		ColumnConfig C7 = new ColumnConfig("salary_rmb", "薪金", 80);
		C7.setNumberFormat(NumberFormat.getCurrencyFormat());  
		C7.setEditor(new CellEditor(new NumberField()));  
		
		columns.add(C7);

		ColumnModel cm = new ColumnModel(columns);
		jobhis_a_grid = new BaseGridPanel(create_job_his_a_Store(), cm,true,true);
		cbs.setSelectionMode(SelectionMode.SINGLE);
		jobhis_a_grid.getBg().setSelectionModel(cbs);
		jobhis_a_grid.getBg().setWidth(650);
		jobhis_a_grid.getBg().setHeight(200);
		return jobhis_a_grid;
	}
	
	
	BaseStore<BusiObject> job_his_t_store = null;
	public BaseStore<BusiObject> get_job_his_t_Store(){
	if(job_his_t_store==null) 
	{
		createStore();
	}
	return job_his_t_store;}
	BaseStore<BusiObject> createStore(){
	ModelType type = new ModelType();
	type.setRoot("records");
	type.setRecordName("record");
	type.setTotalName("totle");
	type.addField("icode");
	type.getField("icode").setType(Long.class);
	type.addField("bcode");
	type.getField("bcode").setType(String.class);
	type.addField("systeminfono");
	type.getField("systeminfono").setType(String.class);
	type.addField("jobstartdate");
	type.getField("jobstartdate").setType(Date.class);
	type.addField("jobenddate");
	type.getField("jobenddate").setType(Date.class);
	type.addField("bcodebefore");
	type.getField("bcodebefore").setType(String.class);
	
	type.addField("salary_rmb");
	type.getField("salary_rmb").setType(Double.class);
	
	type.addField("groupicode");
	type.getField("groupicode").setType(String.class);
	
	type.addField("desc_cn");
	type.getField("desc_cn").setType(String.class);
	
	type.addField("createdate");
	type.getField("createdate").setType(String.class);
	
	StoreInfo info = new StoreInfo();
	info.setTablename("bcode_job_his_t");
	info.setKeyname(new String[] { "icode"});
	info.setSql("select * from bcode_job_his_t  where bcode ='{bcode}'");
	info.setParent(mainstore);// 关联主表
	info.setLinkparentcolumns(new String[] { "bcode" }); // 关联主表字段
	info.setLinkparent_chile_columns(new String[] { "bcode" });// 关联主表字段
	  job_his_t_store = new BaseStore<BusiObject>(type, info);
	 return job_his_t_store;}
	
	
	BaseGridPanel job_his_t_grid=null;
	BaseGridPanel create_job_his_t_Grid(){
	CheckBoxSelectionModel cbs = new CheckBoxSelectionModel();
	List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
	columns.add(cbs.getColumn());

//	ColumnConfig C1 = new ColumnConfig("icode", "icode", 80);
//	columns.add(C1);
//	ColumnConfig C2 = new ColumnConfig("bcode", "bcode", 80);
//	columns.add(C2);
//	ColumnConfig C3 = new ColumnConfig("systeminfono", "systeminfono", 80);
//	columns.add(C3);
//	ColumnConfig C4 = new ColumnConfig("jobstartdate", "工作开始日期", 80);
//	 DateField dateField4 = new DateField();  
//	    dateField4.getPropertyEditor().setFormat(DateTimeFormat.getFormat("yyyy-MM-dd"));  
//	    C4.setEditor(new CellEditor(dateField4));
//	    C4.setDateTimeFormat(DateTimeFormat.getFormat("yyyy-MM-dd"));
//	columns.add(C4);
//	ColumnConfig C5 = new ColumnConfig("jobenddate", "工作结束日期", 80);
//	 DateField dateField5 = new DateField();  
//	    dateField5.getPropertyEditor().setFormat(DateTimeFormat.getFormat("yyyy-MM-dd"));  
//	    C5.setEditor(new CellEditor(dateField5));
//	    C5.setDateTimeFormat(DateTimeFormat.getFormat("yyyy-MM-dd"));
//	columns.add(C5);
//	ColumnConfig C6 = new ColumnConfig("bcodebefore", "所在部门", 80);
//	C6.setEditor(new CellEditor(new TextField<String>()));
//	columns.add(C6);

//	ColumnConfig C7 = new ColumnConfig("salary_rmb", "工资", 80);
//	C7.setEditor(new CellEditor(new TextField<String>()));
//	columns.add(C7);
//	
//	ColumnConfig C8 = new ColumnConfig("groupicode", "工作组", 80);
//	C8.setEditor(new CellEditor(new TextField<String>()));
//	columns.add(C8);
	
	ColumnConfig C9 = new ColumnConfig("desc_cn", "描述", 400);
	//C9.setEditor(new CellEditor(new TextField<String>()));
	columns.add(C9);
	ColumnConfig C10 = new ColumnConfig("createdate", "发生日期", 180);
	//C10.setEditor(new CellEditor(new TextField<String>()));
	columns.add(C10);
	
	ColumnModel cm = new ColumnModel(columns);
	job_his_t_grid = new BaseGridPanel(get_job_his_t_Store(), cm,false,false);
	cbs.setSelectionMode(SelectionMode.SINGLE);
	job_his_t_grid.getBg().setSelectionModel(cbs);
	job_his_t_grid.getBg().setHeight(200);
	return job_his_t_grid ;}

	

	@Override
	public boolean isopen() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean open() {
		// TODO Auto-generated method stub
		return false;
	}

}
